//
//  LoginGenderItemView.swift
//  XGamesLive
//
//  Created by ios on 2024/6/4.
//

import UIKit

class LoginGenderItemView: UIView {
    
    private var imageView: UIImageView!
    private var titleText: UILabel!
    private var normalImage: String = ""
    private var selectImage: String = ""
    
    public var isSelected: Bool = false{
        didSet{
            self.imageView.image = self.isSelected ? imageWithName(self.selectImage) : imageWithName(self.normalImage)
            self.titleText.textColor = isSelected ? UIColor.white : UIColor.hexColor("#A2A2A2")
        }
    }
    public var itemButton: UIButton!

    init(title: String,normalImage: String,selectImage: String) {
        super.init(frame: CGRect.zero)
        self.selectImage = selectImage
        self.normalImage = normalImage
        self.imageView = UIImageView()
        self.titleText = UILabel().then({ make in
            make.font = UIFont.pingfangSC_Semibold(fontSize: 18.0)
            make.text = title
        })
        itemButton = UIButton()
        self.addSubviews([imageView,titleText,itemButton])
        imageView.snp.makeConstraints { make in
            make.centerX.top.equalToSuperview()
            make.height.width.equalTo(120.0)
        }
        titleText.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(imageView.snp.bottom).offset(20.0)
        }
        itemButton.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        self.snp.makeConstraints { make in
            make.width.equalTo(imageView)
            make.bottom.equalTo(titleText)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

